package com.ftg.learn.chpater01;

/**
 * 运算符
 *
 * @author lijiaxin
 * @version 1.0
 * @date 2023/4/8 15:45
 */

public class LearnOptions {

    public static void main(String[] args) {

        int bint=23;
        System.out.printf("23的个数是%d\n",bint%10);
        System.out.printf("23的十数是%d\n",bint/10%10);

        int aint  = 23456;
        System.out.printf("23456的个数是%d\n",aint/1%10);  //10 0次方
        System.out.printf("23456的十数是%d\n",aint/10%10);
        System.out.printf("23456的百位数是%d\n",aint /100%10);
        System.out.printf("23456的千位数是%d\n",aint /1000%10);
        System.out.printf("23456的万位数是%d\n",aint/10000%10);

        System.out.println(3/2.0);

        System.out.println(getPosition(aint,0));
//        求哪个数 Aint，告诉求第几位   ，返回一个整数
//        封装
    }static int getPosition(int aint,int index){
        int sum = 1;
        for (int i = 0; i < index; i++) {
            sum = sum * 10;
        }
        return aint / sum % 10;
    }
}
